package com.ruoyi.web.controller.substation;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SUserOperateRecord;
import com.ruoyi.system.service.ISUserOperateRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工记录Controller
 * 
 * @author ruoyi
 * @date 2023-07-05
 */
@Api(tags = "员工记录管理")
@RestController
@RequestMapping("/substation/operateRecord")
public class SUserOperateRecordController extends BaseController
{
    @Autowired
    private ISUserOperateRecordService sUserOperateRecordService;

    /**
     * 查询员工记录列表
     */
    @ApiOperation("获取员工记录列表")
    @PreAuthorize("@ss.hasPermi('substation:operateRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(SUserOperateRecord sUserOperateRecord)
    {
        startPage();
        List<SUserOperateRecord> list = sUserOperateRecordService.getList(sUserOperateRecord);
        return getDataTable(list);
    }

    /**
     * 导出员工记录列表
     */
    @ApiOperation("导出员工记录列表")
    @PreAuthorize("@ss.hasPermi('substation:operateRecord:export')")
    @Log(title = "员工记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SUserOperateRecord sUserOperateRecord)
    {
        List<SUserOperateRecord> list = sUserOperateRecordService.list(sUserOperateRecord.queryWrapper());
        ExcelUtil<SUserOperateRecord> util = new ExcelUtil<SUserOperateRecord>(SUserOperateRecord.class);
        util.exportExcel(response, list, "员工记录数据");
    }

    /**
     * 获取员工记录详细信息
     */
    @ApiOperation("获取员工记录详细")
    @ApiImplicitParam(name = "id", value = "员工记录ID", required = true, dataType = "String", paramType = "path")
    @PreAuthorize("@ss.hasPermi('substation:operateRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(sUserOperateRecordService.getById(id));
    }

    /**
     * 新增员工记录
     */
    @ApiOperation("新增员工记录")
    @PreAuthorize("@ss.hasPermi('substation:operateRecord:add')")
    @Log(title = "员工记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SUserOperateRecord sUserOperateRecord)
    {
        sUserOperateRecord.setUserId(SecurityUtils.getUserId().toString());
        sUserOperateRecord.setSubmitTime(new Date());
        return toAjax(sUserOperateRecordService.save(sUserOperateRecord));
    }

    /**
     * 修改员工记录
     */
    @ApiOperation("更新员工记录")
    @PreAuthorize("@ss.hasPermi('substation:operateRecord:edit')")
    @Log(title = "员工记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SUserOperateRecord sUserOperateRecord)
    {
        return toAjax(sUserOperateRecordService.updateById(sUserOperateRecord));
    }

    /**
     * 删除员工记录
     */
    @ApiOperation("删除员工记录")
    @ApiImplicitParam(name = "ids", value = "员工记录ID集合", required = true, dataType = "String", paramType = "path")
    @PreAuthorize("@ss.hasPermi('substation:operateRecord:remove')")
    @Log(title = "员工记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<String> ids)
    {
        return toAjax(sUserOperateRecordService.removeByIds(ids));
    }
}
